package com.mybatils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;

/**
 * @author Xiongx
 * @version 1.0
 * @date 2021/5/20 22:42
 * @since JDK 1.8
 */
public class DynamicDataSource extends AbstractRoutingDataSource {


    private static final Logger LOGGER = LoggerFactory.getLogger(DynamicDataSource.class);

    @Override
    protected Object determineCurrentLookupKey() {
        String datasource = DataSourceContextHolder.getDbType();
        LOGGER.debug("使用数据源 {}", datasource);
        return datasource;
    }
}
